﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;

namespace ExcelFileQueryTool
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += Application_ThreadException;

            MessageDispatcherManager.AddDispatcher(new PopupNotifierMessageDispatcher("popup_window_dispatcher"));
            MessageDispatcherManager.AddDispatcher(new LogFileMessageDispatcher("log_file_dispatcher"));

            Application.Run(new frmMain());
        }


        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            var msg = new AppMessage();
            msg.Time = DateTime.Now;
            msg.Level = AppMessageLevel.Info;
            msg.Title = e.Exception.Message;
            msg.Content = e.Exception.ToString();

            MessageDispatcherManager.DispatchMessage(msg);

            msg.Level = AppMessageLevel.Error;
            MessageDispatcherManager.DispatchMessage(msg);

            //using (var f = new frmMessageDetail(msg, detail))
            //{
            //    f.ShowDialog();
            //}
        }
    }
}
